<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

Class Result_model extends Teaboy_model{
	
		public function __contruct(){
			parent::Controller();
		}
		
		public function getLosers($gameId = null){
			//get a list of all players of a game ordered by time completed
			if(empty($gameId)){
				$gameId = $this->getCurrentGame();   //use current game
			}
			
			$aPlayers = $this->getAllPlayers($gameId);
			//print_r($aPlayers);
			//return first record - this is our loser
			return $aPlayers[0];
			
		}
		
		public function getWinners($gameId = null){
			
			if(empty($gameId)){
				$gameId = $this->getCurrentGame();   //use current game
			}
			
			//get a list of all players of game
			$aPlayers = $this->getAllPlayers($gameId);
			//print_r($aPlayers);
			
			unset($aPlayers[0]);
			
			return $aPlayers;
			
		}

		private function getAllPlayers($gameId){
			return $this->Register_model->getAllPlayers($gameId);
		}
		
}
